package com.example.tliasfight.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Slf4j
@Aspect
@Component
public class MyAspect1
{
    @Around("execution(* com.example.tliasfight.controller.DeptController.*(..)) ")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        //获取原始业务方法的类名
       log.info("业务方法的类名是："+joinPoint.getTarget().getClass().getName()) ;
        //获取业务方法的方法名
       log.info("业务方法的方法名是："+ joinPoint.getSignature().getName());
        //获取业务方法的参数
        log.info("业务方法的参数是："+Arrays.toString(joinPoint.getArgs()));
       // 调用原始业务方法,并获取返回值
        Object result =joinPoint.proceed();
        log.info("返回值是:"+result);
        return result ;

    }
    @Before("execution(* com.example.tliasfight.controller.DeptController.*(..))")
    public void before(JoinPoint joinPoint)
    {

    }
}
